package com.bio.action.home;

import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.bio.entity.task.Task;
import com.bio.entity.user.User;
import com.bio.service.task.TaskService;
import com.bio.utils.Environment;
import com.bio.utils.Pager;
import com.bio.utils.Pagination;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("unchecked")
@Namespace("/home")
@Results( { @Result(name = "homepage", location = "/WEB-INF/views/home.jsp", type = "dispatcher"), })
public class HomeAction extends ActionSupport{
	
	private static final long serialVersionUID = -4517286069818249963L;
	
	private User user;
	
	private Pagination pagination = new Pagination();
	
	private Integer currentIndex = 0;
	
	private Pager<Task> taskPager = Pager.EMPTY_PAGE;

	private TaskService taskService;

	public String listHomePage(){
		//TODO
		//商业渠道 channel
		user = Environment.Session.getUser();
		Long companyId = Environment.Session.getCompanyId();
		Long userId = Environment.Session.getUserId();
		pagination.setCurrentIndex(currentIndex);
		
		//我的日程 task
		taskPager = taskService.findPagerByUserId(pagination, userId, null);
		return "homepage";
	}

	public Pager<Task> getTaskPager() {
		return taskPager;
	}

	public void setTaskPager(Pager<Task> taskPager) {
		this.taskPager = taskPager;
	}

	public void setTaskService(TaskService taskService) {
		this.taskService = taskService;
	}

	public void setPagination(Pagination pagination) {
		this.pagination = pagination;
	}

	public void setCurrentIndex(Integer currentIndex) {
		this.currentIndex = currentIndex;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
}
